package com.example.android2019;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.android2019.ch3.Ch3StorageActivity;
import com.example.android2019.ch5broadcast.BroadActivity;
import com.example.android2019.ch6service.ServiceActivity;
import com.example.android2019.homework.homework4.RegisterActivity;
import com.example.android2019.musices.music1.MusicActivity;
import com.example.android2019.note.NoteActivity;

public class MainActivity extends AppCompatActivity {
    Button main_btn1, main_btn2, main_btn3, main_btn4, main_btn5, main_btn6, main_btn7, main_btn8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*关联控件*/
        inti();
        View.OnClickListener clickListener = new View.OnClickListener() {
            @Override
            /*View v这个参数表示点击的是哪个控件*/
            public void onClick(View v) {
                switch (v.getId()) {
                    case R.id.main_btn1:
                        testUI();
                        break;
                    case R.id.main_btn2:
                        Activity();
                        break;
                    case R.id.main_btn3:
                        Sjcunchu();
                        break;
                    case R.id.main_btn4:
                        Nrtgz();
                        break;
                    case R.id.main_btn5:
                        broad();
                        break;
                    case R.id.main_btn6:
                        serve();
                        break;
                    case R.id.main_btn7:
                        jsb();
                        break;
                    case R.id.main_btn8:
                        music();
                        break;
                }
            }
        };
        main_btn1.setOnClickListener(clickListener);
        main_btn2.setOnClickListener(clickListener);
        main_btn3.setOnClickListener(clickListener);
        main_btn4.setOnClickListener(clickListener);
        main_btn5.setOnClickListener(clickListener);
        main_btn6.setOnClickListener(clickListener);
        main_btn7.setOnClickListener(clickListener);
        main_btn8.setOnClickListener(clickListener);
    }


    private void inti() {
        main_btn1 = findViewById(R.id.main_btn1);
        main_btn2 = findViewById(R.id.main_btn2);
        main_btn3 = findViewById(R.id.main_btn3);
        main_btn4 = findViewById(R.id.main_btn4);
        main_btn5 = findViewById(R.id.main_btn5);
        main_btn6 = findViewById(R.id.main_btn6);
        main_btn7 = findViewById(R.id.main_btn7);
        main_btn8 = findViewById(R.id.main_btn8);
    }

    private void music() {
        Intent intent = new Intent(MainActivity.this, MusicActivity.class);
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void jsb() {
        /*跳转*/
        Intent intent = new Intent(MainActivity.this, NoteActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void testUI() {

    }

    private void Activity() {
        /*跳转*/
        Intent intent = new Intent(MainActivity.this, RegisterActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void Sjcunchu() {
        /*跳转*/
        Intent intent = new Intent(MainActivity.this, Ch3StorageActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void Nrtgz() {

    }

    private void broad() {
        /*跳转*/
        Intent intent = new Intent(MainActivity.this, BroadActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void serve() {
        Intent intent = new Intent(MainActivity.this, ServiceActivity.class);
        intent.putExtra("test", "tz");
        startActivity(intent);
    }
}
